package population;

import java.util.ArrayList;

import population.phaseExecutors.PhaseExecutor;

/**
 * The pipeline.
 * @author pcdejager
 */
public class GeneratorPipeline {
    /**
     * Constructor.
     */
    public GeneratorPipeline() {
        executors = new ArrayList<PhaseExecutor>();
    }

    /**
     * Add an executor to pipeline.
     * @param p The executor to add
     */
    public final void addExecutor(final PhaseExecutor p) {
        executors.add(p);
    }

    /**
     * Get the size of the pipeline.
     * @return The size
     */
    public final int size() {
        return executors.size();
    }

    /**
     * Execute the executors on the given population.
     * @param p The population
     */
    public final void execute(final Population p) {
        for (PhaseExecutor e : executors) {
            e.execute(p);
        }
    }

    /**
     * The executors to use.
     */
    private ArrayList<PhaseExecutor> executors = null;
}
